import request from '@/router/axios';
import { getToken } from '@/util/auth';
export const getList = (current, size, params, deptId) => {
  return request({
    url: '/api/blade-system/user/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      deptId
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/blade-system/user/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/blade-system/user/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/blade-system/user/update',
    method: 'post',
    data: row
  });
};

export const updatePlatform = (userId, userType, userExt) => {
  return request({
    url: '/api/blade-system/user/update-platform',
    method: 'post',
    params: {
      userId,
      userType,
      userExt
    }
  });
};

export const getUserSkill = (id) => {
  return request({
    url: '/api/mes-admin/userskill/detail',
    method: 'get',
    params: {
      userId: id
    }
  });
};

export const getUserPlatform = (id) => {
  return request({
    url: '/api/blade-system/user/platform-detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getUserInfo = () => {
  return request({
    url: '/api/blade-system/user/info',
    method: 'get'
  });
};

export const resetPassword = (userIds) => {
  return request({
    url: '/api/blade-system/user/reset-password',
    method: 'post',
    params: {
      userIds
    }
  });
};

export const updatePassword = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: '/api/blade-system/user/update-password',
    method: 'post',
    params: {
      oldPassword,
      newPassword,
      newPassword1
    }
  });
};

export const updateInfo = (row) => {
  return request({
    url: '/api/blade-system/user/update-info',
    method: 'post',
    data: row
  });
};

export const grant = (userIds, roleIds) => {
  return request({
    url: '/api/blade-system/user/grant',
    method: 'post',
    params: {
      userIds,
      roleIds
    }
  });
};

export const unlock = (userIds) => {
  return request({
    url: '/api/blade-system/user/unlock',
    method: 'post',
    params: {
      userIds
    }
  });
};

// export const getDetailTemplate = (id) => {
//     return request({
//         url: '/api/mes-admin/labeltemplate/detail',
//         method: 'get',
//         params: {
//             id
//         }
//     })
// }

export const getTemplateInfo = (id) => {
  return request({
    url: '/api/mes-admin/labeltemplate/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getEquireMentInfo = (id) => {
  return request({
    url: '/api/mes-product/ems-equipment/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getSiteSelect = (tenantId) => {
  return request({
    url: '/api/blade-system/dept/site-select',
    method: 'get',
    params: {
      tenantId
    }
  });
};

export const getWaitBindScopeSyncDataList = (params) => {
  return request({
    url: '/api/blade-system/scopesyncdata/getWaitBindScopeSyncDataList',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const saveOrUpdateScopeSyncData = (params, row) => {
  return request({
    url: '/api/blade-system/scopesyncdata/saveOrUpdateScopeSyncData',
    method: 'post',
    params: {
      ...params
    },
    data: row
  });
};

// 下载 （获取excel模板）
export const getExcelTemplate = (params) => {
  return request({
    url: '/api/blade-system/user/export-template',
    method: 'get',
    responseType: 'blob',
    params
  });
};

// 导出用户文件
export const exportUser = (account, realName) => {
  return request({
    url: '/api/blade-system/user/export-user',
    method: 'get',
    responseType: 'blob',
    headers: {},
    timeout: 30 * 1000,
    params: {
      'Blade-Auth': getToken(),
      account,
      realName
    }
  });
};

export const openPermission = (id) => {
  return request({
    url: `/api/blade-system/user/enable?userIds=${id}`,
    method: 'post'
  });
};

export const closePermission = (id) => {
  return request({
    url: `/api/blade-system/user/disabled?userIds=${id}`,
    method: 'post'
  });
};

export const getUser = (id) => {
  return request({
    url: '/api/blade-system/user/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getWorkStationAll = () => {
  return request({
    url: '/api/mes-product/apaasworkstation/get/all',
    method: 'get'
  });
};

export const userWorkStationSubmit = (userId, userName, data) => {
  return request({
    url: `/api/mes-admin/userworkstation/submit?userId=${userId}&userName=${userName}`,
    method: 'post',
    data: data
  });
};

export const getUserWorkStationDetail = (userId) => {
  return request({
    url: '/api/mes-admin/userworkstation/detail',
    method: 'get',
    params: {
      userId
    }
  });
};
